<?php $this->headStyle()->captureStart()?>
    #content td { padding:5px}
    #content table { border:1px #aaa solid; padding:5px; width:100%}
    #content th {font-weight:bold;}

<?php $this->headStyle()->captureEnd()?>
<?php $this->JQuery()->javascriptCaptureStart()?>
	$j(document).ready(function() {
	
		$j('#company_form').submit(function(e) {
			if ($j('#company_name').attr('value') == ''){
				$j('#company_name').css('border', '1px solid red');
				return false;
			} else {
				$j('#company_name').css('border', 'none');
			}
			
			if ($j('#contact_phone').attr('value') != ''){
		
				if ($j('#contact_phone').attr('value').match(/^\d+$/) == null){
					$j('#contact_phone').css('border', '1px solid red');
					return false;
				} else {
					$j('#contact_phone').css('border', 'none');
				}
			}
			
			if ($j('#business_category').attr('value') == ''){
				$j('#business_category').css('border', '1px solid red');
				return false;
			} else {
				$j('#business_category').css('border', 'none');
			}
		
			
			
		});
		
		$j('#company_name').blur(function() {
		if ($j('#company_name').attr('value') != ''){
			var com_name = '<?php echo $this->company->company_name ?>';
			
			if (com_name!=$j('#company_name').attr('value')) {
				$j.post(
					'/default/index/search-company',
					{data:$j('#company_name').attr('value')},
					function (data) {
						if(data.res == 'not') {
							$j('#contact_phone').css('border', 'yellow');
							return false;
						} else {
							$j('#contact_phone').css('border', 'none');
						}
						
					}
				);
				return false;
			}
		}
	
	});
	
	});
<?php $this->JQuery()->javascriptCaptureEnd()?>

<h2>Edit Info</h2>
<h2><?php echo $this->user->un?></h2>
<br><br>
<form id="company_form" method="post">
Company Name: <input type="text" id="company_name" name="company_name" value="<?php echo $this->company->company_name?>"><br/>
Phone: <input type="text" id="contact_phone" name="contact_phone" value="<?php echo $this->company->phone?>"><br/>
Business Category: <?php
				$bd = Model_Category::one(array('id' => 'mc52'));
				$id = $bd->_id;

				$locs = Model_Category::all(array('_id' => array('$ne' => new MongoId($id)),  'path' => new MongoId($id), 'status' => Model_Category::STATUS_ACTIVE))->sort(array('pos' => 1));
				$parent = '';
				$locations = array(); ?>
				<select name="business_category" id="business_category">
                                    <option value=""><?php echo $this->t('Select')?></option>
                                    <?php foreach($locs as $k => $loc):?>
                                            <?php if (count($loc->path) == 2):?>
                                                    <option value="<?php echo $loc->_id?>" <?php if ($this->company->business_category == $loc->_id) { echo "selected='selected'"; } ?>><?php echo $loc->name?></option>
                                            <?php endif;?>
                                    <?php endforeach; ?>
				</select><br/>
                                District: <?php
				$locs = Model_Location::all()->sort(array('path' => 1));
				$parent = '';
				$locations=array();
				foreach($locs as $k => $loc) {
					if (count($loc->path) == 1) {
						$parent = $loc->name;
						$locations[$loc->name] = array();
					} else {
						$tmp    = !empty($locations[(string) $parent]) ? $locations[(string) $parent] : array();
						$tmp[$k]         = (string) $loc->name;
						$locations[(string) $parent] = $tmp;
					}
				} ?>

				<select name="location" id="location">
						<option value=""><?php echo $this->t('Select')?></option>
					<?php foreach($locations as $k => $locs):?>
						<optgroup label="<?php echo $k?>">
						<?php foreach($locs as $j => $loc):?>
							<option value="<?php echo $j?>" <?php if ($this->company->lo == $j) { echo "selected='selected'"; } ?>><?php echo $loc?></option>
						<?php endforeach;?>
						</optgroup>
					<?php endforeach;?>
				</select><br/>
Mailing Address: <textarea name="mailing_address" id="mailing_address"><?php echo (!empty($this->company->mailing_address)) ? $this->company->mailing_address : ''?></textarea><br/>
Website: <input type="text" name="website" id="website" value="<?php echo (!empty($this->company->website)) ? $this->company->website : 'http://'?>" /><br/>				
First Name: <input type="text" value="<?php echo $this->company->contact_firstname?>" id="contact_firstname" name="contact_firstname"><br/>
Last Name: <input type="text" value="<?php echo $this->company->contact_lastname?>" id="contact_lastname" name="contact_lastname"><br/>
Department: <input type="text" name="contact_department" id="contact_department" value="<?php echo $this->company->contact_department?>"><br/>
Job Title: <input type="text" name="contact_job" id="contact_job" value="<?php echo $this->company->contact_job?>"><br/>
Mobile Phone: <input type="text" name="phone" id="phone" value="<?php echo $this->company->contact_phone?>"><br/>
Email Address: <input type="text" name="contact_email" id="contact_email" value="<?php echo $this->company->contact_email?>"><br/>
About Us: <textarea name="about" id="about"><?php echo $this->company->about?></textarea><br/>				
				
<button>Update</button>
</form>